const parseData = require('./shared/parseData')
function calculate (data, options){
  // 解析数据
  const [commitCount, commitLineCount, authorObj] = parseData(data,options)
  console.log('commitCount, commitLineCount',commitCount, commitLineCount)
  // 计算分数
  const keys = Object.keys(authorObj)
  // 假设提交次数和提交行数各占一半权重。
  keys.forEach(authorID => {
    const obj = authorObj[authorID]
    obj.score = ((((obj.commits.length / commitCount) + (obj.commitLine / commitLineCount)) / 2) * 100).toFixed(2)
  })

  return authorObj
}

module.exports = calculate